package com.hxcy.doki;

import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

public class LoginActivity2 extends AppCompatActivity  implements View.OnClickListener{

    EditText name;
    EditText pwd;
    Button login;

    public static final String USER = "user";
    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_login2);

        name = findViewById(R.id.et_name);
        pwd = findViewById(R.id.et_pwd);
        login = findViewById(R.id.bt_login);
        login.setOnClickListener(this);
    }


    @Override
    public void onClick(View view) {
        if ("123".equals(name.getText().toString())&&"123".equals(pwd.getText().toString())){
            //Toast.makeText(LoginActivity2.this,"登录成功",Toast.LENGTH_SHORT).show();
            User user = new User();
            user.setName(name.getText().toString());
            user.setPwd(pwd.getText().toString());

            Intent intent = new Intent(LoginActivity2.this,UserActivity.class);
            intent.putExtra(USER,user);
            startActivity(intent);
        }else {
            Toast.makeText(LoginActivity2.this,"登录失败",Toast.LENGTH_SHORT).show();
        }
    }
}
